<?php
class artCategoryController extends Controller{

	public function index(){
		$list = $this->model->get_categories();
		$this->assign('list', $list);
		$list = tree($list);
		$this->assign('cats', json_encode($list));
		$this->display('admin/artCategories.html');
	}

	public function add(){
		$data = get_data();
		$rs = $this->model->add($data);
		if( $rs>0 ){
			ajax_return(array('status'=>1));
			exit;
		}
		ajax_return(array('status'=>0));
		exit;
	}	

	public function edit(){
		$data = get_data();
		$id = intval($data['id']);
		unset($data['id']);
		$rs = $this->model->edit($id,$data);
		ajax_return(array('status'=>$rs));
		exit;
	}

	public function del(){
		$id = G('id');
		$rs = $this->model->del($id);
		ajax_return(array('status'=>$rs));
		exit;
	}
}
